import { createSlice,createAsyncThunk } from "@reduxjs/toolkit";
import { getMusicApi } from "../../services/axios";
import type { Bank } from "../../services/axios";


interface MusicList {
    musicList:Bank[]
}

const initialState:MusicList = {
    musicList:[]
}


export const getMusic = createAsyncThunk('music/getMusic', async() => {
    const res = await getMusicApi()
    // console.log(res.data)
    return res.data.value
})



const musicSlice = createSlice({
    name:'music',
    initialState,
    reducers:{

    },
    extraReducers:builder => {
      builder
        .addCase(getMusic.fulfilled,(state,action) => {
            // console.log(action.payload)
            state.musicList = action.payload
        })
    }
        
            

})

// export const {  } = musicSlice.actions
export default musicSlice.reducer